{% extends "admin/base_site.html" %}
{% load i18n grp_tags %}

{% block breadcrumbs %}
    <div id="breadcrumbs">
      <a href="/">{% trans 'Home' %}</a>{% if title %} &rsaquo; {{ title }}{% endif %}
       &rsaquo; My Tests
    </div>
{% endblock %}

{% block stylesheets %}
  {{ block.super }}
  <style type="text/css">
    .minimenu {
      padding: 15px;
    }
  </style>
{% endblock %}

{% block javascripts %}
  {{ block.super }}
  <script src="/static/js/jquery.tools.min.js" type="text/javascript"></script>
  <script type="text/javascript">
    function show_queue(test_id) {
      $.post(  
        "show_queue/",  
        { id: test_id },  
        function(data){  
          $("#student_queue_modal").html(data);
        }  
      );
      
      $("#student_queue_modal").overlay({
          top: '3',
          fixed: false
      });
      
      $("#student_queue_modal").overlay().load();
    }
  </script>
{% endblock %}

{% block content %}
  <h1> Open Metric Recognition </h1>
  
  <div class="module">
    <a class="minimenu" href="{% url ecwsp.omr.views.edit_test %}">{% trans 'Create New Test' %}</a>
    <a class="minimenu" href="{% url admin:omr_questionbank_changelist %}">{% trans 'Question Bank' %}</a>
  </div>
  
  <h2>Your Tests</h2>
  <div class="module changelist-results"> 
    <table cellspacing="0">
      <thead> 
        <tr>
          <th> Test </th>
          <th> MP </th>
          <th> # Questions </th>
          <th> Students </th>
          <th> Student Queue </th>
          <th> Test Results </th>
          <th> Points Possible </th>
        </tr>
      </thead> 
      <tbody>
        {% for test in tests %}
          <tr class="{% if forloop.counter|divisibleby:2 %}row2{% else %}row1{% endif %}">
            <td><a href="{% url ecwsp.omr.views.edit_test test.id %}"> {{ test }} </a></td>
            <td> {{ test.marking_period }} </td>
            <td><a href="{% url ecwsp.omr.views.edit_test_questions test.id %}"> {{ test.question_set.count }} </a></td>
            <td> {{ test.testinstance_set.count }} </td>
            <td> <a href="javascript:;" onclick="show_queue({{ test.id }});">{{ test.students_in_queue }}</a> </td>
            <td>
              {% if test.finalized %}
                <a href="../test_result/{{ test.id }}" > {{ test.students_test_results }} </a>
              {% else %}
                {{ test.students_test_results }}
              {% endif %}
            </td>
            <td> {{ test.points_possible }} </td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
    
    <div class="modal" id="student_queue_modal">.
      OH HAI!
      <button class="close"> Close </button>
    </div>
  </div>
{% endblock %}
